package kr.hkit.androidcomplete03.ch26;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class WordDBHelper extends SQLiteOpenHelper {
	private static final String DB_NAME = "EngWord.db";
	private static final int DB_VERSION = 1;
	private static final String TAG = "SQLiteOpenHelper";

	public WordDBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
		Log.d(TAG, "WordDBHelper()");
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(EngWord.CREATE_TBL);
		for (int i = 0; i < EngWord.INSERT_TBL.length; i++) {
			db.execSQL(EngWord.INSERT_TBL[i]);
		}
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.d(TAG, "onUpgrade() oldVersion = " + oldVersion + "newVersion = "
				+ newVersion);
		db.execSQL(EngWord.DROP_TBL);
		onCreate(db);
	}

}
